<template>
    <div>
        <el-tree
            :data="getTreeList"
            show-checkbox
            node-key="id"
            ref="tree"
            :default-expanded-keys="defaultExpanded"
            :default-checked-keys="defaultChecked"
            @check-change="handleNodeClick"
            :filter-node-method="filterNode"
            >
            <!-- :props="defaultProps" -->
        </el-tree>
    </div>
</template>
<script>
export default {
    props: {
        getTreeList: {//树
            type: Array,
        },
        defaultExpanded: {//默认展开的id数组
            type: Array,
        },
        defaultChecked:{//默认选中的id数组
            type: Array,
        }
    },
    watch: {
    //   defaultChecked(val) {
    //       if(val){
    //           this.$refs.tree.filter('一年级(1)班');
    //       }
    //   }
    },
    methods:{
        handleNodeClick(data,data1,data2) {//勾选节点的时候
            this.$emit('getIdList',this.$refs.tree.getCheckedKeys(true));//勾选的id数组
        },
        filterNode(value, data) {
            
            // console.log(value,'value')
            // console.log(data,'data')
            // if (!value) return true;
            // return data.label.indexOf(value) !== -1;
        }
     
    }
}
</script>

